package com.zyh.util;

import org.springframework.core.io.ClassPathResource;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/**
 * @author wangchengshou
 * @version 1.0
 * @date 2020/12/9 15:37
 */
public class ConfigInfo {
    public static String  getConfigInfoByName(String name){
        //从配置文件读取对应值
        Properties properties = new Properties();
        ClassPathResource classPathResource = new ClassPathResource("esbconfig.properties");
        File file = null;
        String value = null;
        try {
            file = classPathResource.getFile();
            properties.load(new FileReader(file));
            value = properties.getProperty(name);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }

    public static String  getIPConfigInfoByName(String name){
        //从配置文件读取对应值
        Properties properties = new Properties();
        ClassPathResource classPathResource = new ClassPathResource("allowIpLists.properties");
        File file = null;
        String value = null;
        try {
            file = classPathResource.getFile();
            properties.load(new FileReader(file));
            value = properties.getProperty(name);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }



}
